package com.cos.shop.common;

/**
 * Copyright (C),2021-2022,亚瑟王
 * FileName: ResponseResult
 * Author: saber
 * Date:2022/9/16 21:18
 */
public class ResponseResult<T> {

    private int code;
    private String msg;
    private T data;

    public static ResponseResult createSuccess(){
        return new ResponseResult(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMsg());
    }
    public static ResponseResult createSuccess(String msg){
        return new ResponseResult(ResponseCode.SUCCESS.getCode(), msg);
    }
    public static <T> ResponseResult createSuccess(T data){
        return new ResponseResult(ResponseCode.SUCCESS.getCode(), data);
    }
    public static ResponseResult createSuccess(int code){
        return new ResponseResult(code, ResponseCode.SUCCESS.getMsg());
    }
    public static <T> ResponseResult createSuccess(int code,String msg,T data){
        return new ResponseResult(code, msg, data);
    }



    public static ResponseResult createFail(){
        return new ResponseResult(ResponseCode.FAIL.getCode(), ResponseCode.FAIL.getMsg());
    }
    public static ResponseResult createFail(String msg){
        return new ResponseResult(ResponseCode.FAIL.getCode(), msg);
    }
    public static <T> ResponseResult createFail(T data){
        return new ResponseResult(ResponseCode.FAIL.getCode(), data);
    }
    public static ResponseResult createFail(int code){
        return new ResponseResult(code, ResponseCode.FAIL.getMsg());
    }
    public static <T> ResponseResult createFail(int code,String msg,T data){
        return new ResponseResult(code, msg, data);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResponseResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseResult(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResponseResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult(T data) {
        this.data = data;
    }

    public ResponseResult() {
    }
} 
